home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / postscript.674 < prev    next >
Text File  |  1992-02-06  |  2KB  |  64 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f3\fmodern Courier;\f1\fswiss Helvetica;}
  2. \paperw13040
  3. \paperh10800
  4. \margl120
  5. \margr120
  6. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 postscript stack pswrap\
  7. \
  8. Q:  How do I put objects on the PostScript stack from a C program? How do I retrieve them?\
  9. \
  10. A:  In PostScript, objects are placed on the stack simply by mentioning them. For example, when programming directly in PostScript one places an integer object, a floating point object, an array and a string on the stack like this (respectively):\
  11.  
  12. \f3\fs24     1\
  13.     3.1415\
  14.     [(this is a string in an array) 63 9.876 (another string)]\
  15.     (Hello World!)\
  16. \
  17.  
  18. \f0\fs28 For each PostScript operator there is a corresponding pswrap'ed operator whose name is created by prepending "PS" to the operator's name, e.g. the PostScript operator 
  19. \b setgray
  20. \b0  has a C function wrap called 
  21. \b PSsetgray()
  22. \b0 .  This convention is not possible in the above situation where we are referring directly to values.\
  23. \
  24. In their infinite wisdom the creators of the wrapped functions created the following wraps for placing objects on the PostScript stack, and for retrieving them (this list borrowed from the Single-Operator Functions section in the reference manual).\
  25. \
  26.  
  27. \pard\tx4320\tx8660\tx10680\b\fi-1440\li2160 Function    Effect\
  28.  
  29. \b0 PSsendint()    Puts a single value of the specified type on the operand stack\
  30. PSsendfloat()\
  31. PSsendboolean() \
  32. PSsendstring()\
  33.  
  34. \fs16 \
  35.  
  36. \fs28 PSgetint()    Gets a single value of the specified type from the operand stack\
  37. PSgetfloat()\
  38. PSgetboolean() \
  39. PSgetstring()\
  40.  
  41. \fs16 \
  42.  
  43. \fs28 PSsendintarray()    Puts a series of objects on the operand stack\
  44. PSsendfloatarray()\
  45. PSsendchararray()\
  46.  
  47. \fs16 \
  48.  
  49. \fs28 PSgetintarray()    Gets a series of objects from the operand stack\
  50. PSgetfloatarray()\
  51. PSgetchararray()\
  52.  
  53. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  54. You may have noticed that each of the 
  55. \b get
  56. \b0  operators specifies the type of the operand expected on the top of the stack. If the actual type of the object returned is different than expected, an error will occur in the PostScript interpreter. You are responsible for maintaining the stack, the objects that you place there and ensuring that you request the proper type of object. \
  57. \
  58. QA674\
  59. \
  60. Valid for 1.0\
  61. Valid for 2.0\
  62. \
  63.  
  64.